package com.example.dell.wisdom_farm;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTabHost;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.ToggleButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

import android.widget.CompoundButton;

public class IndexActivity extends AppCompatActivity {


    private ToggleButton toggleButton;
    private FragmentTabHost tabHost;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);
        init();
        setTab();


    }




    public void init()
    {
        tabHost=(FragmentTabHost)findViewById(R.id.tabhost);
    }
    public void setTab(){
        FragmentManager fragmentManager=getSupportFragmentManager();
        tabHost.setup( this,fragmentManager,R.id.tablocation);
        tabHost.getTabWidget().setDividerDrawable(null);

        tabHost.addTab(tabHost.newTabSpec( "实时监控1").setIndicator(setTabview("实时环境")),view1.class, null);
        tabHost.addTab(tabHost.newTabSpec( "实时监控2").setIndicator(setTabview("设备控制")),view2.class, null);
        tabHost.addTab(tabHost.newTabSpec( "实时监控3").setIndicator(setTabview("数据分析")),view3.class, null);
        tabHost.addTab(tabHost.newTabSpec( "实时监控4").setIndicator(setTabview("参数设置")),view4.class, null);
    }
    public View setTabview(String title){
        View view=LayoutInflater.from( this ).inflate(R.layout.bottom, null);
        TextView textView=(TextView)view.findViewById(R.id.ceshi1_textview_title);
        textView.setText(title);

        //textView.setTextColor(getResources().getColor(R.color.red));

        return view;
    }
}

